package com.qfedu.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qfedu.entity.BoxEntity;
import com.qfedu.mapper.BoxMapper;
import com.qfedu.service.BoxService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@com.alibaba.dubbo.config.annotation.Service
public class BoxServiceimpl implements BoxService {
    @Autowired(required = false)
    private BoxMapper boxMapper;
    @Override
    public BoxEntity queryBox(int bid) {
        BoxEntity boxEntity = boxMapper.queryBox(bid);
        return boxEntity;
    }

    @Override
    public List<BoxEntity> queryall() {
        return boxMapper.queryall();
    }

    //停启用
    public boolean qiyong(int bid,int bzt){
        return boxMapper.qiyong(bid,bzt);
    }
    //删除
    public boolean delbox(int bid){
        return boxMapper.delbox(bid);
    }
    //修改
    public boolean updbox(BoxEntity be){
        return boxMapper.updbox(be);
    }
    //添加
    public boolean addbox(BoxEntity be){
        return boxMapper.addbox(be);
    }
    //分页
    public PageInfo<BoxEntity> fenyebox(BoxEntity be){
        PageHelper.startPage(be.getPageNum(), be.getPageSize());
        List<BoxEntity> queryall = boxMapper.fenyebox(be);
        //List<BoxEntity> queryall = boxMapper.queryall();
        PageInfo<BoxEntity> pageInfo = new PageInfo<>(queryall);
        return pageInfo;
    }


    //选择删除
    public boolean delByIds(String bids){
        String str = "("+bids.substring(0,bids.length()-1)+")";
        return boxMapper.delByIds(str);
    }
}
